
#include <sstream>
#include <fstream>
#include <iomanip>
#include <string>
#include <clocale>
#include <vector>
#include "room.h"
#include "Building.h"
#include "BuildingDataBase.h"

using namespace std;

void main3_1_2(){

	cout << "main 3_1_2" << endl;

	room r1;
	room r2(12,"kitchen");

	r1.Write();
	r2.Write();
	r1.Read();
	r1.Write();

}

void main3_3(){
	string str = "";
	cout << "main 3_3" << endl;
	room r1;
	room r2(45, "bedroom");
	cout << r1 << endl;
	cout << r2 << endl;

	/*cin >> r1;
	std::getline(cin, str);
	cout << r1 << endl;*/
}

void main3_4(){

	cout << "main 3_4" << endl;
	room r1(24, "bedroom");
	room r2(36, "bathroom");
	room r3(200, "attic");
	room r4(46, "bedroom");

	Building bu;

	bu.add(r1);
	bu.add(r2);
	bu.add(r3);
	bu.add(r4);
	string s = bu.list();
	cout << s << endl;

	cout << "Search bedroom =" << endl;
	cout << bu.SearchRoom("bedroom");

	bu.Delete();

	


}

void main3_5(){
	cout << "main 3_5" << endl;
	
	room r1(24, "bedroom");
	room r2(36, "bathroom");
	room r3(200, "attic");


	Building bu;

	bu.add(r1);
	bu.add(r2);
	bu.add(r3);

	bu.WriteToFile("bu.txt");

}

void main3_6(){
	cout << "main 3_6" << endl;
	Building bu;
	bu.ReadFromFile();
	cout << bu.list();
}  

void main3_7(){
	cout << "main 3_7" << endl;

	room r1(24, "bedroom");
	room r2(36, "bathroom");
	room r3(200, "attic");

	Building bu;

	bu.add(r1);
	bu.add(r2);
	bu.add(r3);
	
	
}

void main4(){
	cout << "main41" << endl;
	BuildingDataBase db;
	int option;
	do
	{

		cout << "1) Read from file " << endl;
		cout << "2) Write to file " << endl;
		cout << "3) Area    " << endl;
		cout << "4) Search" << endl;
		cout << "5) NewBuilding" << endl;
		cout << "6) DeleteBuilding" << endl;
		cout << "7) Exit Program " << endl;
		cout << "Please select an option : ";
		cin >> option;
		if (option == 1)
		{
			string a;
			cout << "File to read:";
			cin >> a;
			db.ReadFromFilesToDatabase(a);
		}
		else if (option == 2) {
			string b;
			cout << "File to write to:";
			cin >> b;
			db.WriteToFile(b);
		}
		else if (option == 3){

			cout << "Area totalt = " << db.Area() << endl;

		}
		else if (option == 4){
			string word;
			cout << "Search for:";
			cin >> word;
			cout << "resultat:" << db.SearchWordInInfo(word) << endl;
		}
		else if (option == 5){

		}
		else if (option == 6){

		}
		else if (option == 7){
				cout << "Terminating Program" << endl;
			}
		else {
			cout << "Invalid Option entered" << endl;
		}
		} while (option != 7);
	return ;
	}
	


int main(){

	main3_1_2();

	main3_3();

	main3_4();
	
	main3_5();

	main3_6();

	main3_7();

	main4();

	system("pause");

	return 0;

}